<?php

declare(strict_types=1);

namespace app\api\controller\v1;


class Wxpay
{
    protected $appid;

    public function init()
    {
        $this->appid = '123';
    }

    /**
     * 下单
     */
    public function create()
    {
        $uri = 'https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi';
        $postData = [
            'appid' => 'wxa0260f54fc4e30b1',    //  公众号/小程序的appid
            'mchid' => '1609270140',         //  商户号
            'description' => '会员价格',    //  商品描述
            'out_trade_no' => 'a121111311',     //  订单号
            'notify_url' => 'https://api.1demo.cc/api/wxpay/notify',    //支付成功，回调地址
            'amount' => [
                'total' => 1,     //  单位：分
                'currency' => 'CNY'
            ],
            'payer' => [
                'openid' => 'qUzn5YHUZ5X08uLqO4_V8PyqLKY'
            ]
        ];
        $res = curlPost($uri, json_encode($postData));
        dd($res);
    }

    /**
     * 支付成功回调
     * */
    public function notify()
    {
        $requestData = input();
        dd($requestData);
    }
}
